require(['./config'], () => {
  require(['swiper', 'template', 'header', 'footer'], (Swiper, template) => {
    class Category {
      constructor () {
        this.getList()
		this.banner()
		this.getTabs()
      }
	  banner () {
	    // swiper本身就是一个满足AMD规范的模块，所以需要在上面接收Swiper
	    var mySwiper = new Swiper('#banner', {
	      loop: true,
	      autoplay: true,
	      pagination: {
	        el: '#banner .banner-pagination',
	      },
	      navigation: {
	        nextEl: '#banner .swiper-button-next',
	        prevEl: '#banner .swiper-button-prev',
	      }
	    })
	  }
      getList () {
        // ?id=356756867
        const id = location.search.slice(4, 5)
		const name = decodeURIComponent(location.search.slice(11))
		
        $.get(`http://www.xiongmaoyouxuan.com/api/tab/${id}`, resp => {
          
          if (resp.code === 200) {
            const { list } = resp.data.items
            const { cname } = resp.data.category
		
            $('#goodsClassify').html(
              template('classifyTempalte', {
                cname,
                list
              })
            )
          }
        })
      }
	  getTabs () {
		  
		  const name = decodeURIComponent(location.search.slice(11))
		   console.log(name)
	        $('#tabList').html(template('tabListTemplate',{ name }))
	     
	  }
	  
    }
    new Category()
  })
})
